<!DOCTYPE html>


<html lang="en">
  

    <head>
      <meta charset="utf-8" />
        
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title>GBase8s表DML逻辑日志观察.md |  朝花夕拾</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/ww.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    </head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-GBase8s表DML逻辑日志观察-md"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  GBase8s表DML逻辑日志观察.md
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/10/01/GBase8s%E8%A1%A8DML%E9%80%BB%E8%BE%91%E6%97%A5%E5%BF%97%E8%A7%82%E5%AF%9F-md/" class="article-date">
  <time datetime="2023-10-01T05:19:56.000Z" itemprop="datePublished">2023-10-01</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">4.1k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">22 min</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="表DML逻辑日志观察"><a href="#表DML逻辑日志观察" class="headerlink" title="表DML逻辑日志观察"></a>表DML逻辑日志观察</h1><h2 id="测试表："><a href="#测试表：" class="headerlink" title="测试表："></a>测试表：</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">drop</span> <span class="keyword">table</span> if <span class="keyword">exists</span> tt;</span><br><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> tt (id <span class="type">int</span>, c1 <span class="type">char</span>(<span class="number">3</span>),c2 <span class="type">char</span>(<span class="number">9</span>),c3 <span class="type">varchar</span>(<span class="number">4</span>), c4 lvarchar(<span class="number">4</span>));</span><br></pre></td></tr></table></figure>

<h2 id="insert测试："><a href="#insert测试：" class="headerlink" title="insert测试："></a>insert测试：</h2><h3 id="插入5条记录："><a href="#插入5条记录：" class="headerlink" title="插入5条记录："></a>插入5条记录：</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt <span class="keyword">values</span>(<span class="number">0</span>,<span class="string">&#x27;abc&#x27;</span>,<span class="string">&#x27;abc&#x27;</span>,<span class="string">&#x27;abc&#x27;</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt(id,c1) <span class="keyword">values</span>(<span class="number">1</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt(id,c2) <span class="keyword">values</span>(<span class="number">2</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt(id,c3) <span class="keyword">values</span>(<span class="number">3</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tt(id,c4) <span class="keyword">values</span>(<span class="number">4</span>,<span class="string">&#x27;abc&#x27;</span>);</span><br></pre></td></tr></table></figure>

<h3 id="观察日志："><a href="#观察日志：" class="headerlink" title="观察日志："></a>观察日志：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">观察日志使用的命令就是 onlog -n xxx -l</span></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">800bc    92   HINSERT  51       0  80084    90010c   101      27</span><br><span class="line">         5c000000 00002800 12410100 00000000 \.....(. .A......</span><br><span class="line">         00000000 00000000 33000000 84000800 ........ 3.......</span><br><span class="line">         37b9a400 0c019000 0c019000 01010000 7....... ........</span><br><span class="line">         1b000000 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000000 61626361 62632020 20202020 ....abca bc</span><br><span class="line">         00036162 63000400 61626300          ..abc... abc.</span><br><span class="line"></span><br><span class="line">81050    88   HINSERT  51       0  81018    90010c   102      22</span><br><span class="line">         58000000 00002800 12010000 00000000 X.....(. ........</span><br><span class="line">         00000000 00000000 33000000 18100800 ........ 3.......</span><br><span class="line">         3bb9a400 0c019000 0c019000 02010000 ;....... ........</span><br><span class="line">         16000004 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000001 61626300 20202020 20202020 ....abc.</span><br><span class="line">         00010000 01010000                   ........</span><br><span class="line"></span><br><span class="line">82050    88   HINSERT  51       0  82018    90010c   103      22</span><br><span class="line">         58000000 00002800 12010000 00000000 X.....(. ........</span><br><span class="line">         00000000 00000000 33000000 18200800 ........ 3.... ..</span><br><span class="line">         3fb9a400 0c019000 0c019000 03010000 ?....... ........</span><br><span class="line">         16000004 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000002 00202061 62632020 20202020 .....  a bc</span><br><span class="line">         00010000 01019000                   ........</span><br><span class="line"></span><br><span class="line">83050    88   HINSERT  51       0  83018    90010c   104      24</span><br><span class="line">         58000000 00002800 12010000 00000000 X.....(. ........</span><br><span class="line">         00000000 00000000 33000000 18300800 ........ 3....0..</span><br><span class="line">         43b9a400 0c019000 0c019000 04010000 C....... ........</span><br><span class="line">         18000004 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000003 00202000 20202020 20202020 .....  .</span><br><span class="line">         00036162 63000101                   ..abc...</span><br><span class="line"></span><br><span class="line">84050    92   HINSERT  51       0  84018    90010c   105      25</span><br><span class="line">         5c000000 00002800 12010000 00000000 \.....(. ........</span><br><span class="line">         00000000 00000000 33000000 18400800 ........ 3....@..</span><br><span class="line">         47b9a400 0c019000 0c019000 05010000 G....... ........</span><br><span class="line">         19000004 00000000 00000000 000000c2 ........ ........</span><br><span class="line">         00000004 00202000 20202020 20202020 .....  .</span><br><span class="line">         00010000 04006162 63000000          ......ab c...</span><br></pre></td></tr></table></figure>

<h3 id="观察小结："><a href="#观察小结：" class="headerlink" title="观察小结："></a>观察小结：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">- 表的行最大长度row size = 29字节，其中表真实数据是24字节，varchar额外需要2字节，lvarchar额外需要3字节。</span><br><span class="line">- varchar额外的2个字节表示： 0001 即实际varchar存储了1个字节。 000100表示存储了1个字节，00表示varchar字段为空。</span><br><span class="line">- lvarchar额外的3个字节表示： 000400 即实际lvarchar存储了4-1个字节。 000101..表示存储了1-1个字节，后面紧跟的01表lvrchar字段为空。</span><br><span class="line">- insert 操作，逻辑日志会把所以字段都赋值，不管是不是在insert语句中指定的字段。</span><br><span class="line">- char 默认赋值为0x20 即“空格”</span><br><span class="line">- varchar 默认赋值为 0x000100 即空</span><br><span class="line">- lvarchar 默认赋值为0x000101 即空</span><br><span class="line">- 简言之，lvarchar长度后面的第一个字节00表示非空，01表示空。这个第一个字节位是比varchar多出的一个控制标识位。</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">- varchar 的上限是：  32765</span><br><span class="line">- lvarchar 的上限是： 32739</span><br></pre></td></tr></table></figure>



<h2 id="update测试："><a href="#update测试：" class="headerlink" title="update测试："></a>update测试：</h2><h3 id="更新5条记录："><a href="#更新5条记录：" class="headerlink" title="更新5条记录："></a>更新5条记录：</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> id <span class="operator">=</span> <span class="number">99</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">0</span>;</span><br><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> c1 <span class="operator">=</span> <span class="string">&#x27;aaa&#x27;</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">1</span>;</span><br><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> c2 <span class="operator">=</span> <span class="string">&#x27;bbb&#x27;</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">2</span>;</span><br><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> c3 <span class="operator">=</span> <span class="string">&#x27;ccc&#x27;</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">3</span>;</span><br><span class="line"><span class="keyword">update</span> tt <span class="keyword">set</span> c4 <span class="operator">=</span> <span class="string">&#x27;ddd&#x27;</span> <span class="keyword">where</span> id <span class="operator">=</span> <span class="number">4</span>;</span><br></pre></td></tr></table></figure>

<h3 id="观察日志：-1"><a href="#观察日志：-1" class="headerlink" title="观察日志："></a>观察日志：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br></pre></td><td class="code"><pre><span class="line">addr     len  type     xid      id link</span><br><span class="line">f5018    56   BEGIN    51       24 0        09/27/2023 00:08:42 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         0bc1a400 00000000 caaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000   </span><br><span class="line">f5050    92   HUPBEF   51       0  f5018    90010c   101      27</span><br><span class="line">         5c000000 00002a00 12012000 00000000 \.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18500f00 ........ 3....P..</span><br><span class="line">         0bc1a400 0c019000 0c019000 01010000 ........ ........</span><br><span class="line">         1b000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000000 61626361 62632020 20202020 ....abca bc</span><br><span class="line">         00036162 63000400 61626320          ..abc... abc</span><br><span class="line">f50ac    92   HUPAFT   51       0  f5050    90010c   101      27</span><br><span class="line">         5c000000 00002b00 12012000 00000000 \.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50500f00 ........ 3...PP..</span><br><span class="line">         0bc1a400 0c019000 0c019000 01010000 ........ ........</span><br><span class="line">         1b000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000063 61626361 62632020 20202020 ...cabca bc</span><br><span class="line">         00036162 63000400 61626320          ..abc... abc</span><br><span class="line">f5108    56   COMMIT   51       0  f50ac    09/27/2023 00:08:42</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 ac500f00 ........ 3....P..</span><br><span class="line">         0bc1a400 00000000 caaa1365 01010000 ........ ...e....</span><br><span class="line">         caaa1365 00000000                   ...e....</span><br><span class="line"></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">f6018    56   BEGIN    51       24 0        09/27/2023 00:08:42 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         0fc1a400 00000000 caaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000                   ....+...</span><br><span class="line">f6050    88   HUPBEF   51       0  f6018    90010c   102      22</span><br><span class="line">         58000000 00002a00 12012000 00000000 X.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18600f00 ........ 3....`..</span><br><span class="line">         0fc1a400 0c019000 0c019000 02010000 ........ ........</span><br><span class="line">         16000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000001 61626300 20202020 20202020 ....abc.</span><br><span class="line">         00010000 01011000                   ........</span><br><span class="line">f60a8    88   HUPAFT   51       0  f6050    90010c   102      22</span><br><span class="line">         58000000 00002b00 12012000 00000000 X.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50600f00 ........ 3...P`..</span><br><span class="line">         0fc1a400 0c019000 0c019000 02010000 ........ ........</span><br><span class="line">         16000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000001 61616100 20202020 20202020 ....aaa.</span><br><span class="line">         00010000 01010000                   ........</span><br><span class="line">f6100    56   COMMIT   51       0  f60a8    09/27/2023 00:08:42</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 a8600f00 ........ 3....`..</span><br><span class="line">         0fc1a400 00000000 caaa1365 02010000 ........ ...e....</span><br><span class="line">         caaa1365 00000000                   ...e....</span><br><span class="line"></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">f7018    56   BEGIN    51       24 0        09/27/2023 00:08:42 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         13c1a400 00000000 caaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000                   ....+...</span><br><span class="line">f7050    88   HUPBEF   51       0  f7018    90010c   103      22</span><br><span class="line">         58000000 00002a00 12012000 00000000 X.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18700f00 ........ 3....p..</span><br><span class="line">         13c1a400 0c019000 0c019000 03010000 ........ ........</span><br><span class="line">         16000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000002 00202061 62632020 20202020 .....  a bc</span><br><span class="line">         00010000 01013207                   ......2.</span><br><span class="line">f70a8    88   HUPAFT   51       0  f7050    90010c   103      22</span><br><span class="line">         58000000 00002b00 12012000 00000000 X.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50700f00 ........ 3...Pp..</span><br><span class="line">         13c1a400 0c019000 0c019000 03010000 ........ ........</span><br><span class="line">         16000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000002 00202062 62622020 20202020 .....  b bb</span><br><span class="line">         00010000 01010000                   ........</span><br><span class="line">f7100    56   COMMIT   51       0  f70a8    09/27/2023 00:08:42</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 a8700f00 ........ 3....p..</span><br><span class="line">         13c1a400 00000000 caaa1365 03010000 ........ ...e....</span><br><span class="line">         caaa1365 00000000                   ...e....</span><br><span class="line"></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">f8018    56   BEGIN    51       24 0        09/27/2023 00:08:42 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         17c1a400 00000000 caaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000                   ....+...</span><br><span class="line">f8050    88   HUPBEF   51       0  f8018    90010c   104      24</span><br><span class="line">         58000000 00002a00 12012000 00000000 X.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18800f00 ........ 3.......</span><br><span class="line">         17c1a400 0c019000 0c019000 04010000 ........ ........</span><br><span class="line">         18000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000003 00202000 20202020 20202020 .....  .</span><br><span class="line">         00036162 63000101                   ..abc...</span><br><span class="line">f80a8    88   HUPAFT   51       0  f8050    90010c   104      24</span><br><span class="line">         58000000 00002b00 12012000 00000000 X.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50800f00 ........ 3...P...</span><br><span class="line">         17c1a400 0c019000 0c019000 04010000 ........ ........</span><br><span class="line">         18000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000003 00202000 20202020 20202020 .....  .</span><br><span class="line">         00036363 63000101                   ..ccc...</span><br><span class="line">f8100    56   COMMIT   51       0  f80a8    09/27/2023 00:08:42</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 a8800f00 ........ 3.......</span><br><span class="line">         17c1a400 00000000 caaa1365 04010000 ........ ...e....</span><br><span class="line">         caaa1365 00000000                   ...e....</span><br><span class="line"></span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">f9018    56   BEGIN    51       24 0        09/27/2023 00:08:43 43       gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         1bc1a400 00000000 cbaa1365 00000000 ........ ...e....</span><br><span class="line">         ef030000 2b000000                   ....+...</span><br><span class="line">f9050    92   HUPBEF   51       0  f9018    90010c   105      25</span><br><span class="line">         5c000000 00002a00 12012000 00000000 \.....*. .. .....</span><br><span class="line">         00000000 00000000 33000000 18900f00 ........ 3.......</span><br><span class="line">         1bc1a400 0c019000 0c019000 05010000 ........ ........</span><br><span class="line">         19000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000004 00202000 20202020 20202020 .....  .</span><br><span class="line">         00010000 04006162 63000000          ......ab c...</span><br><span class="line">f90ac    92   HUPAFT   51       0  f9050    90010c   105      25</span><br><span class="line">         5c000000 00002b00 12012000 00000000 \.....+. .. .....</span><br><span class="line">         00000000 00000000 33000000 50900f00 ........ 3...P...</span><br><span class="line">         1bc1a400 0c019000 0c019000 05010000 ........ ........</span><br><span class="line">         19000000 00000000 00000000 000000c6 ........ ........</span><br><span class="line">         00000004 00202000 20202020 20202020 .....  .</span><br><span class="line">         00010000 04006464 64000200          ......dd d...</span><br><span class="line">f9108    56   COMMIT   51       0  f90ac    09/27/2023 00:08:43</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 ac900f00 ........ 3.......</span><br><span class="line">         1bc1a400 00000000 cbaa1365 05010000 ........ ...e....</span><br><span class="line">         cbaa1365 00000000                   ...e....</span><br><span class="line">[gbasedbt@wei07 ~]$</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="观察小结：-1"><a href="#观察小结：-1" class="headerlink" title="观察小结："></a>观察小结：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">- 如果表里面不存在可变长字段，那么update是不会存储，变动前后行数据的。而只存储变动前后对应字节的的内容。</span><br><span class="line">- int类型占用4个字节，99对应0x63，这是数字对应。</span><br><span class="line">- char/varchar/lvarchar，是编码对应。包括数字字符。</span><br><span class="line">- 可以很简单的从前后镜像观察得到表的DML操作内容。</span><br></pre></td></tr></table></figure>



<p>延展：如果表里面不包含varchar字段，那么update日志不会包含前后镜像</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">可以发现表里面不包含varchar字段时update日志只有：BEGIN + HUPDAT + COMMIT ；并没有前镜像页，和后镜像页.</span> </span><br><span class="line">addr     len  type     xid      id link</span><br><span class="line">19018    56   BEGIN    51       24 0        09/26/2023 22:36:29 4        gbasedbt</span><br><span class="line">         38000000 18000100 00000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 00000000 ........ 3.......</span><br><span class="line">         23b2a400 00000000 2d951365 00000000 #....... -..e....</span><br><span class="line">         ef030000 04000000                   ........</span><br><span class="line">19050    80   HUPDAT   51       0  19018    90010c   103      0        16  16  1</span><br><span class="line">         50000000 00004900 12002000 00000000 P.....I. .. .....</span><br><span class="line">         00000000 00000000 33000000 18900100 ........ 3.......</span><br><span class="line">         23b2a400 0c019000 0c019000 03010000 #....... ........</span><br><span class="line">         00000000 10001000 01000000 00000000 ........ ........</span><br><span class="line">         7075626c 00070004 61626320 64656620 publ.... abc def</span><br><span class="line">190a0    56   COMMIT   51       0  19050    09/26/2023 22:36:29</span><br><span class="line">         38000000 00000200 10000000 00000000 8....... ........</span><br><span class="line">         00000000 00000000 33000000 50900100 ........ 3...P...</span><br><span class="line">         23b2a400 00000000 2d951365 03010000 #....... -..e....</span><br><span class="line">         2d951365 00000000                   -..e....</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>注明： 对于不包含varchar字段的表的逻辑日志解读，此处不先做展开。</p>
<hr>
<p>​		下文打算先写一下从逻辑日志里面反向推导出DML语句的工具，当然我们先不做太复杂的工具，例如我们先不考虑事务，多条语句，多行数据，特殊字段类型，等情况，我们先做一下最简单的单行变动的DML语句回推。</p>
<h2 id="打捞条件准备"><a href="#打捞条件准备" class="headerlink" title="打捞条件准备"></a>打捞条件准备</h2><h5 id="4个文件"><a href="#4个文件" class="headerlink" title="4个文件"></a>4个文件</h5><p>打捞前请先准备好这4个文件： 逻辑日备份文件，insert语句执行的位置文件，update语句执行的位置文件，表的字段信息文件。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">char *f_llog=&quot;/home/gbasedbt/wangwei/gbase8sTabDML/wei07_108_Log0000000024&quot;;</span><br><span class="line">char *f_insert=&quot;/home/gbasedbt/wangwei/gbase8sTabDML/insert.llog&quot;;</span><br><span class="line">char *f_update=&quot;/home/gbasedbt/wangwei/gbase8sTabDML/update.llog&quot;;</span><br><span class="line">char *f_column=&quot;/home/gbasedbt/wangwei/gbase8sTabDML/column.llog&quot;;</span><br></pre></td></tr></table></figure>



<ul>
<li>表结构</li>
</ul>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> tt (id <span class="type">int</span>, c1 <span class="type">char</span>(<span class="number">3</span>),c2 <span class="type">char</span>(<span class="number">9</span>),c3 <span class="type">varchar</span>(<span class="number">4</span>), c4 lvarchar(<span class="number">4</span>));</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">[root@wei07 wei06-tab-dml-demo]# cat /home/gbasedbt/wangwei/gbase8sTabDML/column.llog</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">name  <span class="built_in">type</span>  size</span></span><br><span class="line">id int 4</span><br><span class="line">c1 char 3</span><br><span class="line">c2 char 9</span><br><span class="line">c3 varchar 4</span><br><span class="line">c4 lvarchar 4</span><br><span class="line">  </span><br></pre></td></tr></table></figure>

<ul>
<li>逻辑日志备份</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/home/gbasedbt/wangwei/gbase8sTabDML/wei07_108_Log0000000024</span><br></pre></td></tr></table></figure>

<ul>
<li><p>逻辑日志insert开始位置及长度</p>
<p>cat &gt; &#x2F;home&#x2F;gbasedbt&#x2F;wangwei&#x2F;gbase8sTabDML&#x2F;insert.llog</p>
</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">begin   len  <span class="built_in">type</span></span> </span><br><span class="line">800bc 92 HINSERT</span><br><span class="line">81050 88 HINSERT</span><br><span class="line">82050 88 HINSERT</span><br><span class="line">83050 88 HINSERT</span><br><span class="line">84050 92 HINSERT</span><br></pre></td></tr></table></figure>

<ul>
<li>逻辑日志updateBEF和updateAFT开始位置及长度</li>
</ul>
<p>cat &gt; &#x2F;home&#x2F;gbasedbt&#x2F;wangwei&#x2F;gbase8sTabDML&#x2F;update.llog</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">begin   len  BEF_type    begin   len  AFT_type</span> </span><br><span class="line">f5050 92 HUPBEF f50ac 92 HUPAFT</span><br><span class="line">f6050 88 HUPBEF f60a8 88 HUPAFT</span><br><span class="line">f7050 88 HUPBEF f70a8 88 HUPAFT</span><br><span class="line">f8050 88 HUPBEF f80a8 88 HUPAFT</span><br><span class="line">f9050 92 HUPBEF f90ac 92 HUPAFT</span><br></pre></td></tr></table></figure>

<h2 id="从insert逻辑日志中捞出insert语句"><a href="#从insert逻辑日志中捞出insert语句" class="headerlink" title="从insert逻辑日志中捞出insert语句"></a>从insert逻辑日志中捞出insert语句</h2><h5 id="从逻辑日志中捞取insertSQL语句的c程序代码"><a href="#从逻辑日志中捞取insertSQL语句的c程序代码" class="headerlink" title="从逻辑日志中捞取insertSQL语句的c程序代码"></a>从逻辑日志中捞取insertSQL语句的c程序代码</h5><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdlib.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;string.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> *语句：</span></span><br><span class="line"><span class="comment"> * drop table if exists tt;</span></span><br><span class="line"><span class="comment"> * create table tt (id int, c1 char(3),c2 char(9),c3 varchar(4), c4 lvarchar(4));</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * insert into tt values(0,&#x27;abc&#x27;,&#x27;abc&#x27;,&#x27;abc&#x27;,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * insert into tt(id,c1) values(1,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * insert into tt(id,c2) values(2,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * insert into tt(id,c3) values(3,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * insert into tt(id,c4) values(4,&#x27;abc&#x27;);</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * update tt set id = 99 where id = 0;</span></span><br><span class="line"><span class="comment"> * update tt set c1 = &#x27;aaa&#x27; where id = 1;</span></span><br><span class="line"><span class="comment"> * update tt set c2 = &#x27;bbb&#x27; where id = 2;</span></span><br><span class="line"><span class="comment"> * update tt set c3 = &#x27;ccc&#x27; where id = 3;</span></span><br><span class="line"><span class="comment"> * update tt set c4 = &#x27;ddd&#x27; where id = 4;</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> *insert语句日志： /home/gbasedbt/wangwei/gbase8sTabDML/insert.llog</span></span><br><span class="line"><span class="comment"> * #begin   len  type </span></span><br><span class="line"><span class="comment"> * 800bc 92 HINSERT</span></span><br><span class="line"><span class="comment"> * 81050 88 HINSERT</span></span><br><span class="line"><span class="comment"> * 82050 88 HINSERT</span></span><br><span class="line"><span class="comment"> * 83050 88 HINSERT</span></span><br><span class="line"><span class="comment"> * 84050 92 HINSERT</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> *update语句日志： /home/gbasedbt/wangwei/gbase8sTabDML/update.llog</span></span><br><span class="line"><span class="comment"> * #begin   len  BEF_type    begin   len  AFT_type </span></span><br><span class="line"><span class="comment"> * f5050 92 HUPBEF f50ac 92 HUPAFT</span></span><br><span class="line"><span class="comment"> * f6050 88 HUPBEF f60a8 88 HUPAFT</span></span><br><span class="line"><span class="comment"> * f7050 88 HUPBEF f70a8 88 HUPAFT</span></span><br><span class="line"><span class="comment"> * f8050 88 HUPBEF f80a8 88 HUPAFT</span></span><br><span class="line"><span class="comment"> * f9050 92 HUPBEF f90ac 92 HUPAFT</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> *字段长度： /home/gbasedbt/wangwei/gbase8sTabDML/column.llog</span></span><br><span class="line"><span class="comment"> * #name  type  size</span></span><br><span class="line"><span class="comment"> * id int 4</span></span><br><span class="line"><span class="comment"> * c1 char 3</span></span><br><span class="line"><span class="comment"> * c2 char 9</span></span><br><span class="line"><span class="comment"> * c3 varchar 4</span></span><br><span class="line"><span class="comment"> * c4 lvarchar 4</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">extern</span> <span class="type">void</span> <span class="title function_">deleteSpace</span><span class="params">(<span class="type">char</span> *str)</span>;</span><br><span class="line"><span class="keyword">extern</span> <span class="type">char</span> *<span class="title function_">utf8decode</span><span class="params">(<span class="type">char</span> *src)</span>;</span><br><span class="line"></span><br><span class="line"><span class="type">int</span> insert_row=<span class="number">5</span>;</span><br><span class="line"><span class="type">int</span> update_row=<span class="number">5</span>;</span><br><span class="line"></span><br><span class="line"><span class="type">char</span> *f_llog=<span class="string">&quot;/home/gbasedbt/wangwei/gbase8sTabDML/wei07_108_Log0000000024&quot;</span>;</span><br><span class="line"><span class="type">char</span> *f_insert=<span class="string">&quot;/home/gbasedbt/wangwei/gbase8sTabDML/insert.llog&quot;</span>;</span><br><span class="line"><span class="type">char</span> *f_update=<span class="string">&quot;/home/gbasedbt/wangwei/gbase8sTabDML/update.llog&quot;</span>;</span><br><span class="line"><span class="type">char</span> *f_column=<span class="string">&quot;/home/gbasedbt/wangwei/gbase8sTabDML/column.llog&quot;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// typedef struct TT</span></span><br><span class="line"><span class="comment">// &#123;</span></span><br><span class="line"><span class="comment">//    int id;</span></span><br><span class="line"><span class="comment">//    char c1[3];</span></span><br><span class="line"><span class="comment">//    char c2[9];</span></span><br><span class="line"><span class="comment">//    char c3[4];</span></span><br><span class="line"><span class="comment">//    char c4[4];</span></span><br><span class="line"><span class="comment">// &#125; tt_t;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> <span class="title">Column</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    <span class="type">char</span> c_name[<span class="number">30</span>];</span><br><span class="line">    <span class="type">char</span> c_type[<span class="number">30</span>];</span><br><span class="line">    <span class="type">int</span> c_def_len;</span><br><span class="line">    <span class="type">int</span> c_use_len;</span><br><span class="line">&#125; <span class="type">colunm_t</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> <span class="title">Insert</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> begin;</span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> len;</span><br><span class="line">&#125; <span class="type">insert_begin_t</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> <span class="title">Update</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> bef_begin;</span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> bef_len;</span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> aft_begin;</span><br><span class="line">    <span class="type">long</span> <span class="type">int</span> aft_len;</span><br><span class="line">&#125; <span class="type">update_begin_t</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 临时存放字段值</span></span><br><span class="line"><span class="type">char</span> dst[<span class="number">32767</span>] = &#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">int</span> argc, <span class="type">char</span> <span class="type">const</span> *argv[])</span></span><br><span class="line">&#123;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 存放日志解析结果</span></span><br><span class="line">    <span class="comment">// tt_t inset[insert_row];</span></span><br><span class="line">    <span class="comment">// tt_t update_bef[update_row];</span></span><br><span class="line">    <span class="comment">// tt_t update_aft[update_row];</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 存放insert begin len</span></span><br><span class="line">    <span class="type">insert_begin_t</span> i_b[insert_row];</span><br><span class="line">    <span class="type">update_begin_t</span> u_b[update_row];</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 打开输入文件</span></span><br><span class="line">    <span class="comment">// FILE *fp_llog=fopen(f_llog,&quot;rb&quot;);  //由于备份后的逻辑日志有包装，放弃直接读备份文件，改由读取备份文件onlog后的文件</span></span><br><span class="line">    FILE *fp_insert=fopen(f_insert,<span class="string">&quot;r&quot;</span>);</span><br><span class="line">    FILE *fp_update=fopen(f_update,<span class="string">&quot;r&quot;</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 读取insert文件</span></span><br><span class="line">    <span class="type">int</span> i = <span class="number">0</span>; </span><br><span class="line">    <span class="type">char</span> line[<span class="number">200</span>];</span><br><span class="line">    <span class="keyword">while</span> (fgets(line,<span class="number">200</span>,fp_insert))&#123;</span><br><span class="line">        <span class="type">char</span> *str_tmp_line[<span class="number">3</span>];</span><br><span class="line">        <span class="type">char</span> *str_tmp;</span><br><span class="line">        <span class="type">int</span> col=<span class="number">0</span>;</span><br><span class="line">        str_tmp = strtok(line,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        <span class="keyword">while</span> (str_tmp != <span class="literal">NULL</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            str_tmp_line[col]=str_tmp;</span><br><span class="line">            col++;</span><br><span class="line">            str_tmp=strtok(<span class="literal">NULL</span>,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(!<span class="built_in">strncmp</span>(str_tmp_line[<span class="number">2</span>],<span class="string">&quot;HINSERT&quot;</span>,<span class="number">7</span>))&#123;</span><br><span class="line">            <span class="built_in">sscanf</span>(str_tmp_line[<span class="number">0</span>],<span class="string">&quot;%x&quot;</span>,&amp;(i_b[i].begin));</span><br><span class="line">            i_b[i].len=atoi(str_tmp_line[<span class="number">1</span>]);</span><br><span class="line">            i++;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    i=<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span> (i &lt; insert_row)&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;%d %d\n&quot;</span>,i_b[i].begin,i_b[i].len);</span><br><span class="line">        i++;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 读取update文件</span></span><br><span class="line">    i = <span class="number">0</span>; </span><br><span class="line">    <span class="keyword">while</span> (fgets(line,<span class="number">200</span>,fp_update))&#123;</span><br><span class="line">        <span class="type">char</span> *str_tmp_line[<span class="number">6</span>];</span><br><span class="line">        <span class="type">char</span> *str_tmp;</span><br><span class="line">        <span class="type">int</span> col=<span class="number">0</span>;</span><br><span class="line">        str_tmp = strtok(line,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        <span class="keyword">while</span> (str_tmp != <span class="literal">NULL</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            str_tmp_line[col]=str_tmp;</span><br><span class="line">            col++;</span><br><span class="line">            str_tmp=strtok(<span class="literal">NULL</span>,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(!<span class="built_in">strncmp</span>(str_tmp_line[<span class="number">2</span>],<span class="string">&quot;HUPBEF&quot;</span>,<span class="number">7</span>))&#123;</span><br><span class="line">            <span class="built_in">sscanf</span>(str_tmp_line[<span class="number">0</span>],<span class="string">&quot;%x&quot;</span>,&amp;(u_b[i].bef_begin));</span><br><span class="line">            u_b[i].bef_len=atoi(str_tmp_line[<span class="number">1</span>]);</span><br><span class="line">            <span class="built_in">sscanf</span>(str_tmp_line[<span class="number">3</span>],<span class="string">&quot;%x&quot;</span>,&amp;(u_b[i].aft_begin));</span><br><span class="line">            u_b[i].aft_len=atoi(str_tmp_line[<span class="number">4</span>]);</span><br><span class="line">            i++;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    i=<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span> (i &lt; update_row)&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;%d %d %d %d\n&quot;</span>,u_b[i].bef_begin,u_b[i].bef_len,u_b[i].aft_begin,u_b[i].aft_len);</span><br><span class="line">        i++;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 截取逻辑日志段</span></span><br><span class="line">    <span class="comment">// //由于备份后的逻辑日志有包装，放弃直接读备份文件，改由读取备份文件onlog后的文件</span></span><br><span class="line">    <span class="comment">// fseek(fp_llog,i_b[0].begin+64+24576,SEEK_SET);</span></span><br><span class="line">    <span class="comment">// i=64;</span></span><br><span class="line">    <span class="comment">// int c;</span></span><br><span class="line">    <span class="comment">// while (i&lt;i_b[0].len)&#123;</span></span><br><span class="line">    <span class="comment">//     c=getc(fp_llog);</span></span><br><span class="line">    <span class="comment">//     printf(&quot;%02x\n&quot;,c);</span></span><br><span class="line">    <span class="comment">//     i++;</span></span><br><span class="line">    <span class="comment">// &#125;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 截取逻辑日志段</span></span><br><span class="line">    <span class="type">char</span> cmd[<span class="number">200</span>] = <span class="string">&quot;echo &#x27;\n&#x27; |onlog -d &quot;</span>;</span><br><span class="line">    <span class="built_in">strcat</span>(cmd,f_llog);</span><br><span class="line">    <span class="built_in">strcat</span>(cmd,<span class="string">&quot; -l &gt; /tmp/onlog.log&quot;</span>);</span><br><span class="line">    system(cmd);</span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">     * 行读取 起始地址匹配</span></span><br><span class="line"><span class="comment">     * 取len/16行，向上取整</span></span><br><span class="line"><span class="comment">     * 取这些行的[9-44]左闭右开字节</span></span><br><span class="line"><span class="comment">     * 字节合并成字节串</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">    i=<span class="number">0</span>;</span><br><span class="line">    <span class="type">int</span> j=<span class="number">0</span>;</span><br><span class="line">    <span class="type">int</span> line_i = <span class="number">0</span>;</span><br><span class="line">    <span class="type">int</span> line_count = <span class="number">0</span>;</span><br><span class="line">    <span class="type">char</span> begin_0x[<span class="number">8</span>];</span><br><span class="line">    <span class="type">char</span> *data[insert_row];</span><br><span class="line">    <span class="keyword">while</span> (j&lt;insert_row)&#123;</span><br><span class="line">        data[j]=<span class="built_in">malloc</span>(<span class="number">2048</span>);</span><br><span class="line">        <span class="type">char</span> temp[<span class="number">36</span>] = &#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">        i = <span class="number">0</span>; </span><br><span class="line">        line_i = <span class="number">0</span>;</span><br><span class="line">        line_count=(i_b[j].len+<span class="number">16</span><span class="number">-1</span>)/<span class="number">16</span>;</span><br><span class="line">        FILE *fp_llog=fopen(<span class="string">&quot;/tmp/onlog.log&quot;</span>,<span class="string">&quot;r&quot;</span>);</span><br><span class="line">        <span class="keyword">while</span> (fgets(line,<span class="number">200</span>,fp_llog))&#123;</span><br><span class="line">            <span class="built_in">sprintf</span>(begin_0x,<span class="string">&quot;%x&quot;</span>,i_b[j].begin);</span><br><span class="line">            <span class="keyword">if</span> (line_i!=<span class="number">0</span> &amp;&amp; i&gt;(line_i+<span class="number">4</span>))&#123;</span><br><span class="line">                <span class="comment">// printf(&quot;%s&quot;,line);</span></span><br><span class="line">                <span class="comment">// 数据段合并成字节串</span></span><br><span class="line">                <span class="built_in">strncpy</span>(temp,line+<span class="number">9</span>,<span class="number">44</span><span class="number">-9</span>);</span><br><span class="line">                <span class="comment">// printf(&quot;--%s--\n&quot;,temp);</span></span><br><span class="line">                <span class="built_in">strcat</span>(data[j],temp);</span><br><span class="line">                <span class="keyword">if</span> (i==(line_i+line_count))&#123;</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">memcmp</span>(begin_0x, line,<span class="built_in">strlen</span>(begin_0x)))&#123;</span><br><span class="line">                line_i=i;</span><br><span class="line">            &#125;</span><br><span class="line">            i++;</span><br><span class="line">        &#125;</span><br><span class="line">        fclose(fp_llog);</span><br><span class="line">        <span class="comment">// 去掉合并后的空格</span></span><br><span class="line">        deleteSpace(data[j]);</span><br><span class="line">        <span class="comment">// printf(&quot;%s\n&quot;,data[j]);</span></span><br><span class="line">        <span class="comment">// printf(&quot;%d\n&quot;,strlen(data[j]));</span></span><br><span class="line">        j++;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 接受字段的列表</span></span><br><span class="line">    <span class="type">colunm_t</span> columns[<span class="number">100</span>];</span><br><span class="line">    <span class="type">short</span> <span class="type">int</span> colNumber;</span><br><span class="line">    <span class="comment">// 读取字段文件输入,逐一以取字段信息</span></span><br><span class="line">    FILE *fp_column = fopen(f_column,<span class="string">&quot;r&quot;</span>);</span><br><span class="line">    j=<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span> (fgets(line,<span class="number">200</span>,fp_column))&#123;</span><br><span class="line">        <span class="comment">//忽略#开头的行</span></span><br><span class="line">        <span class="keyword">if</span> (!<span class="built_in">strncmp</span>(line,<span class="string">&quot;#&quot;</span>,<span class="number">1</span>)) <span class="keyword">continue</span>;</span><br><span class="line">        <span class="comment">//提取文本中表的：字段名称，类型，长度</span></span><br><span class="line">        <span class="type">char</span> *str_tmp_line[<span class="number">3</span>];</span><br><span class="line">        <span class="type">char</span> *str_tmp;</span><br><span class="line">        <span class="type">int</span> col = <span class="number">0</span>;</span><br><span class="line">        str_tmp = strtok(line,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        <span class="keyword">while</span> (str_tmp != <span class="literal">NULL</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            str_tmp_line[col]=str_tmp;</span><br><span class="line">            col++;</span><br><span class="line">            str_tmp=strtok(<span class="literal">NULL</span>,<span class="string">&quot; &quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="type">colunm_t</span> column ;</span><br><span class="line">        <span class="built_in">strcpy</span>(column.c_name,str_tmp_line[<span class="number">0</span>]);</span><br><span class="line">        <span class="built_in">strcpy</span>(column.c_type,str_tmp_line[<span class="number">1</span>]);</span><br><span class="line">        column.c_def_len=atoi(str_tmp_line[<span class="number">2</span>]);</span><br><span class="line">        columns[j]=column;</span><br><span class="line">        j++;</span><br><span class="line">    &#125;</span><br><span class="line">    colNumber=j;</span><br><span class="line">    <span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;colNumber;i++)&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;%s %s %d %d\n&quot;</span>,columns[i].c_name,columns[i].c_type,columns[i].c_def_len,columns[i].c_use_len);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 对字节串按表字段拆分</span></span><br><span class="line">    <span class="type">int</span> row_n;</span><br><span class="line">    <span class="keyword">for</span>(row_n=<span class="number">0</span>;row_n&lt;insert_row;row_n++)&#123;</span><br><span class="line">        <span class="comment">// 接受insert的值</span></span><br><span class="line">        <span class="type">char</span> sql[<span class="number">500</span>] =&#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">        <span class="type">char</span> *insert_sql_beg = <span class="string">&quot;insert into tt values ( &quot;</span>;</span><br><span class="line">        <span class="type">char</span> *insert_sql_end = <span class="string">&quot; );&quot;</span>;</span><br><span class="line">        <span class="built_in">strcpy</span>(sql,insert_sql_beg);</span><br><span class="line">        <span class="comment">//日志里面的一条data</span></span><br><span class="line">        <span class="comment">// printf(&quot;%s %d\n&quot;,data[row_n],strlen(data[row_n]));</span></span><br><span class="line">        <span class="type">char</span> *p = data[row_n];</span><br><span class="line">        <span class="comment">//用字段取拆分日志</span></span><br><span class="line">        <span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;colNumber;i++)&#123;</span><br><span class="line">            <span class="comment">// printf(&quot;%d\n&quot;,i);</span></span><br><span class="line">            <span class="type">colunm_t</span> column = columns[i];</span><br><span class="line"></span><br><span class="line">            <span class="comment">// 处理 int</span></span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">strcmp</span>(column.c_type,<span class="string">&quot;int&quot;</span>))&#123;</span><br><span class="line">                column.c_use_len = column.c_def_len;</span><br><span class="line">                <span class="type">char</span> var_id[<span class="number">9</span>] = &#123;<span class="string">&#x27;\0&#x27;</span>&#125; ;</span><br><span class="line">                <span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;<span class="number">8</span>;j++)&#123;</span><br><span class="line">                    var_id[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">// printf(&quot;%s\n&quot;,var_id);</span></span><br><span class="line">                <span class="comment">//返回一个10进制数字的字符串</span></span><br><span class="line">                <span class="type">char</span> result[<span class="number">11</span>];</span><br><span class="line">                <span class="comment">//16进制字符串转int</span></span><br><span class="line">                <span class="type">int</span> v_int;</span><br><span class="line">                <span class="built_in">sscanf</span>(var_id,<span class="string">&quot;%x&quot;</span>,&amp;v_int);</span><br><span class="line">                <span class="comment">//int转字符串</span></span><br><span class="line">                <span class="built_in">sprintf</span>(result, <span class="string">&quot;%d&quot;</span>, v_int);</span><br><span class="line">                <span class="comment">//insert语句值拼接</span></span><br><span class="line">                <span class="built_in">strcat</span>(sql,result);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;,&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            <span class="comment">// 处理 char</span></span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">strcmp</span>(column.c_type,<span class="string">&quot;char&quot;</span>))&#123;</span><br><span class="line">                column.c_use_len = column.c_def_len;</span><br><span class="line">                <span class="type">char</span> var_c1[column.c_use_len*<span class="number">2</span>+<span class="number">1</span>];</span><br><span class="line">                var_c1[column.c_use_len*<span class="number">2</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">                <span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;column.c_use_len*<span class="number">2</span>;j++)&#123;</span><br><span class="line">                    var_c1[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">// printf(&quot;%s\n&quot;,var_c1);</span></span><br><span class="line">                <span class="comment">//空值判断</span></span><br><span class="line">                <span class="keyword">if</span> (var_c1[<span class="number">0</span>]==<span class="string">&#x27;0&#x27;</span> &amp;&amp; var_c1[<span class="number">1</span>]==<span class="string">&#x27;0&#x27;</span>)&#123;</span><br><span class="line">                    <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                    <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);  </span><br><span class="line">                    <span class="keyword">continue</span>;                  </span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">//返回一个字节串</span></span><br><span class="line">                <span class="comment">//utf8 解码decode</span></span><br><span class="line">                utf8decode(var_c1);</span><br><span class="line">                <span class="comment">//insert语句值拼接</span></span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,dst);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            <span class="comment">// 处理 varchar</span></span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">strcmp</span>(column.c_type,<span class="string">&quot;varchar&quot;</span>))&#123;</span><br><span class="line">                <span class="comment">//先取前2个字节</span></span><br><span class="line">                <span class="type">char</span> nc[<span class="number">5</span>]=&#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">                <span class="keyword">for</span> (j=<span class="number">0</span>;j&lt;<span class="number">4</span>;j++)&#123;</span><br><span class="line">                    nc[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">//16进制字符串转int</span></span><br><span class="line">                <span class="type">int</span> nc_i;</span><br><span class="line">                <span class="built_in">sscanf</span>(nc,<span class="string">&quot;%x&quot;</span>,&amp;nc_i);</span><br><span class="line">                <span class="comment">//再指定长度</span></span><br><span class="line">                column.c_use_len = nc_i;</span><br><span class="line">                <span class="comment">//再取字字符串</span></span><br><span class="line">                <span class="type">char</span> var_c2[column.c_use_len*<span class="number">2</span>+<span class="number">1</span>];</span><br><span class="line">                var_c2[column.c_use_len*<span class="number">2</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">                <span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;column.c_use_len*<span class="number">2</span>;j++)&#123;</span><br><span class="line">                    var_c2[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">// printf(&quot;%s\n&quot;,var_c2);</span></span><br><span class="line">                <span class="comment">//空值判断</span></span><br><span class="line">                <span class="keyword">if</span> (var_c2[<span class="number">0</span>]==<span class="string">&#x27;0&#x27;</span> &amp;&amp; var_c2[<span class="number">1</span>]==<span class="string">&#x27;0&#x27;</span>)&#123;</span><br><span class="line">                    <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                    <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);  </span><br><span class="line">                    <span class="keyword">continue</span>;                  </span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">//返回一个字节串</span></span><br><span class="line">                utf8decode(var_c2);</span><br><span class="line">                <span class="comment">//insert语句值拼接</span></span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,dst);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);</span><br><span class="line">            &#125;    </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            <span class="comment">// 处理 lvarchar</span></span><br><span class="line">            <span class="keyword">if</span> (!<span class="built_in">strcmp</span>(column.c_type,<span class="string">&quot;lvarchar&quot;</span>))&#123;</span><br><span class="line">                <span class="comment">//先取前2个字节</span></span><br><span class="line">                <span class="type">char</span> nc[<span class="number">5</span>]=&#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">                <span class="keyword">for</span> (j=<span class="number">0</span>;j&lt;<span class="number">4</span>;j++)&#123;</span><br><span class="line">                    nc[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">//16进制字符串转int</span></span><br><span class="line">                <span class="type">int</span> nc_i;</span><br><span class="line">                <span class="built_in">sscanf</span>(nc,<span class="string">&quot;%x&quot;</span>,&amp;nc_i);</span><br><span class="line">                <span class="comment">//再指定长度</span></span><br><span class="line">                column.c_use_len = nc_i<span class="number">-1</span>;</span><br><span class="line">                <span class="comment">//取1字节的控制位</span></span><br><span class="line">                p++;</span><br><span class="line">                p++;</span><br><span class="line">                <span class="comment">//再取字字符串</span></span><br><span class="line">                <span class="type">char</span> var_c3[column.c_use_len*<span class="number">2</span>+<span class="number">1</span>];</span><br><span class="line">                var_c3[column.c_use_len*<span class="number">2</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">                <span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;column.c_use_len*<span class="number">2</span>;j++)&#123;</span><br><span class="line">                    var_c3[j]=*p++;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="comment">// printf(&quot;%s\n&quot;,var_c3);</span></span><br><span class="line">                <span class="comment">//返回一个字节串</span></span><br><span class="line">                utf8decode(var_c3);</span><br><span class="line">                <span class="comment">//insert语句值拼接</span></span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;&quot;</span>);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,dst);</span><br><span class="line">                <span class="built_in">strcat</span>(sql,<span class="string">&quot;&#x27;,&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="type">char</span> sql_end[<span class="number">1000</span>]=&#123;<span class="string">&#x27;\0&#x27;</span>&#125;;</span><br><span class="line">        <span class="built_in">strncpy</span>(sql_end,sql,<span class="built_in">strlen</span>(sql)<span class="number">-1</span>);</span><br><span class="line">        <span class="built_in">strcat</span>(sql_end,insert_sql_end);</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;%s\n&quot;</span>,sql_end);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 关闭文件</span></span><br><span class="line">    fclose(fp_insert);</span><br><span class="line">    fclose(fp_update);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">deleteSpace</span><span class="params">(<span class="type">char</span> *str)</span>&#123;</span><br><span class="line">    <span class="type">char</span> *str_c=str;</span><br><span class="line">    <span class="type">int</span> i,j =<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">for</span>(i=<span class="number">0</span>;str[i]!=<span class="string">&#x27;\0&#x27;</span>;i++)&#123;</span><br><span class="line">        <span class="keyword">if</span>(str[i]!=<span class="string">&#x27; &#x27;</span>)</span><br><span class="line">            str_c[j++]=str[i];</span><br><span class="line">    &#125;</span><br><span class="line">    str_c[j]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">    str=str_c;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">char</span> *<span class="title function_">utf8decode</span><span class="params">(<span class="type">char</span> *src)</span>&#123;</span><br><span class="line">    <span class="type">int</span> n;</span><br><span class="line">    n=<span class="built_in">strlen</span>(src);</span><br><span class="line">    <span class="keyword">if</span> (n==<span class="number">0</span>) &#123;</span><br><span class="line">        dst[<span class="number">0</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">        <span class="keyword">return</span> dst;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="type">char</span> cmd[n+<span class="number">20</span>];</span><br><span class="line">    <span class="built_in">strcpy</span>(cmd,<span class="string">&quot;utf8decode -s &quot;</span>);</span><br><span class="line">    <span class="built_in">strcat</span>(cmd,src);</span><br><span class="line">    FILE *fp = <span class="literal">NULL</span>;</span><br><span class="line">    fp = popen(cmd,<span class="string">&quot;r&quot;</span>);</span><br><span class="line">    <span class="keyword">if</span>(fp==<span class="literal">NULL</span>)&#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;POPEN ERROR!\n&quot;</span>);</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;errot&quot;</span>;</span><br><span class="line">    &#125;   </span><br><span class="line">    dst[<span class="number">0</span>]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">    <span class="type">char</span> buffer = fgetc(fp);</span><br><span class="line">    dst[<span class="number">0</span>]=buffer;</span><br><span class="line">    <span class="type">int</span> cnt =<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span> (!feof(fp))</span><br><span class="line">    &#123;</span><br><span class="line">        cnt++;</span><br><span class="line">        buffer=fgetc(fp);</span><br><span class="line">        dst[cnt]=buffer;</span><br><span class="line">    &#125;</span><br><span class="line">    dst[--cnt]=<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">    pclose(fp);</span><br><span class="line">    <span class="keyword">return</span> dst;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h5 id="utf8字节码解码："><a href="#utf8字节码解码：" class="headerlink" title="utf8字节码解码："></a>utf8字节码解码：</h5><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> main</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;fmt&quot;</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;encoding/hex&quot;</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;log&quot;</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;flag&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 注明：这个程序可以用c写，由于时间问题先外挂golang解决。</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> src = flag.String(<span class="string">&quot;s&quot;</span>,<span class="string">&quot;616263&quot;</span>,<span class="string">&quot;decode utf8 []byte&quot;</span>)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">        flag.Parse()</span><br><span class="line">        src2 := []<span class="type">byte</span>(*src)</span><br><span class="line">        dst := <span class="built_in">make</span>([]<span class="type">byte</span>,hex.DecodedLen(<span class="built_in">len</span>(src2)))</span><br><span class="line">        n,err := hex.Decode(dst,src2)</span><br><span class="line">        <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">           log.Fatal(err)</span><br><span class="line">        &#125;</span><br><span class="line">        fmt.Printf(<span class="string">&quot;%s\n&quot;</span>,dst[:n])</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h5 id="编译执行，从逻辑日志中捞取insertSQL语句："><a href="#编译执行，从逻辑日志中捞取insertSQL语句：" class="headerlink" title="编译执行，从逻辑日志中捞取insertSQL语句："></a>编译执行，从逻辑日志中捞取insertSQL语句：</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">[root@wei07 wei06-tab-dml-demo]# gcc main.c  &amp;&amp; ./a.out </span><br><span class="line">524476 92</span><br><span class="line">528464 88</span><br><span class="line">532560 88</span><br><span class="line">536656 88</span><br><span class="line">540752 92</span><br><span class="line">1003600 92 1003692 92</span><br><span class="line">1007696 88 1007784 88</span><br><span class="line">1011792 88 1011880 88</span><br><span class="line">1015888 88 1015976 88</span><br><span class="line">1019984 92 1020076 92</span><br><span class="line">id int 4 0</span><br><span class="line">c1 char 3 0</span><br><span class="line">c2 char 9 0</span><br><span class="line">c3 varchar 4 0</span><br><span class="line">c4 lvarchar 4 0</span><br><span class="line">insert into tt values ( 0,&#x27;abc&#x27;,&#x27;abc      &#x27;,&#x27;abc&#x27;,&#x27;abc&#x27; );</span><br><span class="line">insert into tt values ( 1,&#x27;abc&#x27;,&#x27;&#x27;,&#x27;&#x27;,&#x27;&#x27; );</span><br><span class="line">insert into tt values ( 2,&#x27;&#x27;,&#x27;abc      &#x27;,&#x27;&#x27;,&#x27;&#x27; );</span><br><span class="line">insert into tt values ( 3,&#x27;&#x27;,&#x27;&#x27;,&#x27;abc&#x27;,&#x27;&#x27; );</span><br><span class="line">insert into tt values ( 4,&#x27;&#x27;,&#x27;&#x27;,&#x27;&#x27;,&#x27;abc&#x27; );</span><br><span class="line">[root@wei07 wei06-tab-dml-demo]# </span><br></pre></td></tr></table></figure>





<h2 id="从update逻辑日志中捞出update语句"><a href="#从update逻辑日志中捞出update语句" class="headerlink" title="从update逻辑日志中捞出update语句"></a>从update逻辑日志中捞出update语句</h2><p>​		有空再完善。。</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>Copyright： </strong>
          
          Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://example.com/2023/10/01/GBase8s%E8%A1%A8DML%E9%80%BB%E8%BE%91%E6%97%A5%E5%BF%97%E8%A7%82%E5%AF%9F-md/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SQL%E8%AF%AD%E5%8F%A5%E6%8F%90%E5%8F%96/" rel="tag">SQL语句提取</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/level3/" rel="tag">level3</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%87%AA%E7%A0%94/" rel="tag">自研</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%80%BB%E8%BE%91%E6%97%A5%E5%BF%97%E8%A7%A3%E6%9E%90/" rel="tag">逻辑日志解析</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
    
      <a href="/2023/08/20/Java%E7%BA%BF%E7%A8%8B%E5%90%8C%E6%AD%A5-%E9%93%B6%E8%A1%8C%E5%8F%96%E5%8F%B7%E5%8F%AB%E5%8F%B7%E4%B8%9A%E5%8A%A1%E5%9C%BA%E6%99%AF-md/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">Java线程同步--银行取号叫号业务场景.md</div>
      </a>
    
  </nav>

  
   
  
    
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2023-2024
        <i class="ri-heart-fill heart_icon"></i> Wang Wei
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ww.ico" alt="朝花夕拾"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>